package com.bosssoft.ct.springcloud.service;

import com.bosssoft.ct.springcloud.pojo.dto.UserDTO;
import com.bosssoft.ct.springcloud.pojo.query.UserQuery;
import com.bosssoft.ct.springcloud.utils.http.HttpResult;
import org.springframework.stereotype.Component;

/**
 * 降级熔断兜底方法 解耦的方式实现
 * @author ChenTong
 * @version 1.0
 * @date 2020/6/22 21:48
 * @copyright
 * @modified
 * @see
 * @since
 **/
@Component
public class UserHystrixFallBackService implements UserFeignService {

    @Override
    public HttpResult getUsers(UserQuery userQuery) {
        return HttpResult.error("超时请重试");
    }

    @Override
    public HttpResult update(UserDTO userDTO) {
        return HttpResult.error("更新失败,请重试");
    }

    @Override
    public HttpResult delete(Long id) {
        return HttpResult.error("删除失败,请重试");
    }

    @Override
    public HttpResult insert(UserDTO userDTO) {
        return HttpResult.error("插入失败,请重试");
    }

    //    测试降级以及熔断用
    @Override
    public HttpResult ok() {
        return HttpResult.error("fallback ok error");
    }

    @Override
    public HttpResult testTimeout() {
        return HttpResult.error("fallback testTimeout：");
    }

    @Override
    public HttpResult error() {
        return HttpResult.error("fallback error");
    }
}
